<template>
  <div class="appoint-detail">
    <div style="margin-bottom: .2rem">
      <group>
        <cell title="日期">{{detail.visitDate}}</cell>
        <cell title="出诊状态" v-if="detail.visitStatus == 'on'">出诊</cell>
        <cell title="出诊状态" v-else>休息</cell>
        <cell title="预约数量">{{detail.planAmount}}</cell>
        <cell title="实际预约">{{count}}</cell>
      </group>
    </div>
    <div v-if="dataList.length">
      <div class="flex-box-align" style="padding: 10px 15px;background: #fff;">
        <div class="flex">病患姓名</div>
        <div>看诊时间</div>
      </div>
      <!--<scroller  lock-x scrollbar-y height="-40" use-pullup :pullup-config="pullupConfig2" ref="demo2" @on-pullup-loading="load2">-->
        <group>
          <cell :title="item.patientUserCoreDTO.trueName" v-for="(item, index) in dataList" :key="index">{{item.orderDate}}</cell>
        </group>
        <div v-if="noData" class="no-data">没有更多内容</div>
      <!--</scroller>-->

    </div>
    <div v-else style="font-size:14px;color: #666;text-align: center">没有更多数据</div>
  </div>
</template>
<script>
  import {parseUrlParams} from "../../../wechat/static/util/util.js";
  import {Group, Cell, Scroller} from "vux";
  let CONSTANT = require('../../../wechat/static/constant/constant.js'),
    common = require("../../../wechat/static/common/common.js"),
    wsService = require("../../../wechat/static/common/wechat-jsdk.js");

  export default {
    data() {
      return {
        date: "",
        detail: {},
        dataList: [],
        pullupConfig2: {
          content: '上拉加载更多',
          downContent: '松开进行加载',
          upContent: '上拉加载更多',
          loadingContent: '加载中...'
        },
        pageIndex:1,
        count: null,
        dataForm:'',
        loading:true,
        noData:false
      }
    },
    components: {
      Group, Cell, Scroller
    },
    mounted() {
      this.date = decodeURIComponent(parseUrlParams("date"))

      this.getDetail();

    },
    methods: {
      getDetail() {
        common.requestAjax(CONSTANT.URL.VISIT.PLANDETAIL, JSON.stringify({visitDate: this.date}), {}, (res) => {
          if (res.status == 200) {
              this.detail = res.data.bussData;
              this.getList();
          }
        })
      },
//      load2 () {
//        if(!this.loading) return false;
//        let { pageIndex, pageCount} = this.dataForm;
//        if (pageCount <= this.pageIndex){
//          setTimeout(() => {
//            this.$refs.demo2.disablePullup()
//            this.noData = true
//          }, 100)
//          return false;
//        }
//        this.loading = false;
//        this.pageIndex++;
//        setTimeout(() => {
//          this.getList()
//          this.$refs.demo2.donePullup()
//        }, 100)
//      },
      getList() {
        let url = CONSTANT.URL.VISIT.APPOINTLIST,
          param = {pageIndex: this.pageIndex, pageSize: this.detail.planAmount}
        common.requestAjax(url, JSON.stringify({queryDate: this.date}), param, (res) => {
          if (res.status == 200) {
            this.loading = true;
            let data = res.data,
              pageCount = data.pageCount,
              bussData = data.bussData
            this.count = data.count;
            this.dataForm = data;
            this.dataList = this.pageIndex <= pageCount ? this.dataList.concat(bussData) : this.dataList
          } else {

          }
        })
      }
    }
  };
</script>
<style lang="less">
  .xs-plugin-pullup-container{
    font-size: 12px;
    bottom: -50px;
  }
  .no-data{
    padding-top: .5rem;
    color: #999;
    font-size: 14px;
    bottom: 0rem;
    text-align: center;
    position: relative;
  }
  .record-cell {
    border-left: .04rem solid #0063AE;
    padding-left: .14rem;
    position: relative;
  }

  .p40 {
    padding: .4rem .3rem 0 .3rem;
  }

  .appoint-detail {
    font-size: .34rem;
    height: 100%;
    background: #f4f4f4;
    .weui-cells {
      margin-top: 0!important;
      font-size: .32rem!important;
    }
  }
</style>
